package org.mcflier.appuntamento.data.model;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.mcflier.appuntamento.data.model.abstracts.AbstractTorrentList;
import org.mcflier.appuntamento.i18n.Language;

public class TorrentList extends AbstractTorrentList {
	
	private String title;
	private String link;
	private String description;
	private Timestamp pubDate;
	private Timestamp lastBuildDate;
	private Language language;
	private List<TorrentListItem> items;

	public TorrentList(String sourceLink, String title, String link, String description, Timestamp pubDate, Timestamp lastBuildDate, Language language) {
		super(sourceLink);
		
		this.title = title;
		this.link = link;
		this.description = description;
		this.pubDate = pubDate;
		this.lastBuildDate = lastBuildDate;
		this.language = language;
		this.items = new ArrayList<TorrentList.TorrentListItem>();
	}
	
	public TorrentList(String sourceLink, String title, String link){
		super(sourceLink);
		
		this.title = title;
		this.link = link;
		this.description = null;
		this.pubDate = null;
		this.lastBuildDate = null;
		this.language = null;
		this.items = new ArrayList<TorrentList.TorrentListItem>();
	}
	
	@Override
	public String getTitle() {
		return this.title;
	}

	@Override
	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public String getLink() {
		return this.link;
	}

	@Override
	public void setLink(String link) {
		this.link = link;
	}

	@Override
	public String getDescription() {
		return this.description;
	}

	@Override
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public Timestamp getPubDate() {
		return this.pubDate;
	}

	@Override
	public void setPubDate(Timestamp pubDate) {
		this.pubDate = pubDate;
	}

	@Override
	public Timestamp getLastBuildDate() {
		return this.lastBuildDate;
	}
	
	@Override
	public void setLastBuildDate(Timestamp lastBuildDate) {
		this.lastBuildDate = lastBuildDate;
	}

	@Override
	public Language getLanguage() {
		return this.language;
	}

	@Override
	public void setLanguage(Language language) {
		this.language = language;
	}
	
	@Override
	public void addItem(TorrentListItem item) {
		this.items.add(item);
	}

	@Override
	public List<TorrentList.TorrentListItem> getItems() {
		return this.items;
	}
	
	public class TorrentListItem{
		private String title, weblink, guid, description, comment, category, creator, infoHash, magnetUri;
		private Timestamp pubDate;
		long contentLength;
		
		public TorrentListItem(String title, String link, String guid, long contentLength, String description, String comment, Timestamp pubDate, String creator, String infoHash, String magnetUri) {
			this.title = title;
			this.weblink = link;
			this.guid = guid;
			this.description = description;
			this.comment = comment;
			this.pubDate = pubDate;
			this.creator = creator;
			this.infoHash = infoHash;
			this.contentLength = contentLength;
			this.magnetUri = magnetUri;
			
		}

		public TorrentListItem(String title, String link) {
			this.title = title;
			this.weblink = link;
			this.guid = null;
			this.description = null;
			this.comment = null;
			this.pubDate = null;
			this.contentLength = 0;
			this.creator = null;
			this.infoHash = null;
			this.magnetUri = null;
		}

		public String getTitle() {
			return title;
		}

		public void setTitle(String title) {
			this.title = title;
		}

		public String getWeblink() {
			return weblink;
		}

		public void setWeblink(String link) {
			this.weblink = link;
		}

		public String getGuid() {
			return guid;
		}

		public void setGuid(String guid) {
			this.guid = guid;
		}

		public String getDescription() {
			return description;
		}

		public void setDescription(String description) {
			this.description = description;
		}

		public String getComment() {
			return comment;
		}

		public void setComment(String comment) {
			this.comment = comment;
		}

		public Timestamp getPubDate() {
			return pubDate;
		}

		public void setPubDate(Timestamp pubDate) {
			this.pubDate = pubDate;
		}

		public String getCategory() {
			return category;
		}

		public void setCategory(String category) {
			this.category = category;
		}

		public String getCreator() {
			return creator;
		}

		public void setCreator(String creator) {
			this.creator = creator;
		}

		public String getInfoHash() {
			return infoHash;
		}

		public void setInfoHash(String infoHash) {
			this.infoHash = infoHash;
		}

		public String getMagnetUri() {
			return magnetUri;
		}

		public void setMagnetUri(String magnetUri) {
			this.magnetUri = magnetUri;
		}

		public long getContentLength() {
			return contentLength;
		}

		public void setContentLength(long contentLength) {
			this.contentLength = contentLength;
		}
	}
}